/* ==================================================================   
 * Created [2009-4-27 下午11:32:55] by Jon.King 
 * ==================================================================  
 * TSS 
 * ================================================================== 
 * mailTo:jinpujun@hotmail.com
 * Copyright (c) Jon.King, 2009-2012 
 * ================================================================== 
*/

package com.jinhe.tss.core.cachepool.threadpool.arrayThreadPool;

import junit.framework.TestCase;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import com.jinhe.tss.core.cachepool.threadpool._Scanner;

/** 
 * <p> SimplePortScanner.java </p> 
 * 
 * @author 金普俊 2007-1-8
 */

public class SimplePortScanner extends TestCase{
    
    /**
     * 测试池机制。</p><p>
     * 包括ReusablePool的checkout，checkIn等操作 和 ThreadPool的机制（包括worker池和work队列）
     */
    public static void testPool(){
        ArrayThreadPool tpool = new ArrayThreadPool(6); 
        
        try {
            Thread.sleep(3000); // 休眠3s，等待池初始化结束
        } catch (InterruptedException e) {
        }
        
        for (int i = 12; i <= 28; i++) {
            _Scanner s = new _Scanner();
            s.setHost("127.0.0.1");
            s.setPort(i);

            tpool.excute(s);
        }
        System.out.println("工作队列填充完毕！");
        
        try {
            Thread.sleep(6000); // 休眠6s，等待扫描结束
        } catch (InterruptedException e) {
        }
    }
    
    public static void main(String[] args) {
        Logger.getRootLogger().setLevel(Level.DEBUG);
        
        testPool();
    }

}


